package com.caochenlei.principle.liskovSubstitution;

/*
public class LiskovSubstitution1 {
    public static void main(String[] args) {
        CalcCommon calcCommon = new CalcCommon();
        calcCommon.add(100, 20);
        calcCommon.sub(100, 20);

        System.out.println("--------------------");

        SubCalcCommon subCalcCommon = new SubCalcCommon();
        subCalcCommon.add(100, 20);
        subCalcCommon.sub(100, 20);
    }
}

class CalcCommon {
    //通用加法运算
    public void add(int a, int b) {
        System.out.println(a + "+" + b + "=" + (a + b));
    }

    //通用减法运算
    public void sub(int a, int b) {
        System.out.println(a + "-" + b + "=" + (a - b));
    }
}

class SubCalcCommon extends CalcCommon {
    //子类重写父类的方法可能会改变父类方法的意思，从而导致继承体系崩溃
    @Override
    public void add(int a, int b) {
        System.out.println(a + "*" + b + "=" + (a * b));
    }

    //子类重写父类的方法可能会改变父类方法的意思，从而导致继承体系崩溃
    @Override
    public void sub(int a, int b) {
        System.out.println(a + "/" + b + "=" + (a / b));
    }
}
*/

